package april.fastjson.byte_javabean;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.SerializeWriter;
import com.alibaba.fastjson.serializer.SerializerFeature;

public class User {
	private Long id;
	private String name;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public static void main(String[] args) {
		User user = new User();
		user.setId(1L);
		user.setName("andy");

		byte[] b = Serialize.toJSONStringBytes(user,
				SerializerFeature.UseSingleQuotes);
		for (int i : b) {
			System.out.println(i);
		}

		// 反序列化
		User user2 = JSON.parseObject(b, User.class);
		System.out.println(user2.getId() + " " + user2.getName());

	}
}
